#include <iostream>
#include <vector>

using namespace std;

vector<vector<string>> ret;
vector<string> path;
int n = 0;

bool isPalinedrome(string s, int left, int right)
{
    while (left < right)
    {
        if (s[left++] != s[right--])
            return false;
    }
    return true;
}

void dfs(string s ,int i)
{
    if (i == n)
    {
        ret.push_back(path);
        return;
    }

    for (int j = i; j < n; ++j)
    {
        if (isPalinedrome(s, i, j))
        {
            path.push_back(s.substr(i, j - i + 1));
            dfs(s , j + 1);
            path.pop_back();
        }
    }
}

vector<vector<string>> partition(string s) {
    n = s.size();

    dfs(s , 0);

    return ret;
}

int main()
{
    partition("aab");
	return 0;
}